<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>关联选项</title>
    <c:import url="../../header.jsp"/>
</head>
<body>

<div class="content-warp">
    <div class="bg-warp">
        <div>已关联选项</div>
        <table class="dggui-table cell-border table-form nodeTable">
            <thead>
            <th>序号</th>
            <th>选项名称</th>
            <th>选项code</th>
            <th>选项分值</th>
            <th>选项加分类型</th>
            <th colspan="2">操作</th>
            </thead>
            <tbody>
            <c:if test="${empty matchedOptions}">
                <tr>
                    <td colspan="8">暂无已绑定选项</td>
                </tr>
            </c:if>
            <c:if test="${!empty matchedOptions}">
                <c:forEach items="${matchedOptions}" var="key" varStatus="index">
                    <tr>
                        <td>${index.index+1}</td>
                        <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsName}" /></td>
                        <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsCode}" /></td>
                        <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsScore}" /></td>
                        <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsScoreType == 1 ? "加分":"扣分"}" /></td>
                        <td>
                            <a href="javascript:void(0)" class="dggui-icon-btn" onclick="editOption('${key.id}',1)" ><i class="iconfont icon-shanchu"></i></a>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
            </tbody>
        </table>
        <div>未关联选项</div>
        <table class="dggui-table cell-border table-form nodeTable">
            <thead>
            <th>序号</th>
            <th>选项名称</th>
            <th>选项code</th>
            <th>选项分值</th>
            <th>选项加分类型</th>
            <th colspan="2">操作</th>
            </thead>
            <tbody>
            <c:if test="${empty noMatchedOptions}">
                <tr>
                    <td colspan="8">暂无已绑定选项</td>
                </tr>
            </c:if>
            <c:if test="${!empty noMatchedOptions}">
                <c:forEach items="${noMatchedOptions}" var="key" varStatus="index">
                    <tr>
                    <td>${index.index+1}</td>
                    <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsName}" /></td>
                    <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsCode}" /></td>
                    <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsScore}" /></td>
                    <td><input type="text" class="dggui-input" maxlength="50" disabled value="${key.optionsScoreType == 1 ? "加分":"扣分"}" /></td>
                    <td>
                        <a href="javascript:void(0)" class="dggui-icon-btn" onclick="editOption('${key.id}',2)" ><i class="iconfont icon-tianjia"></i></a>
                    </td>
                </tr>
                </c:forEach>
            </c:if>
            </tbody>
        </table>
        <input type="hidden" id="subjectId" value="${subjectId}">
        <%--<div class="txt-center">--%>
            <%--<button class="dggui-btn" onclick="saveNodeFlow();">保存</button>--%>
        <%--</div>--%>
    </div>
</div>
<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script>
    function editOption(optionId , type) {
        var title = "";
        if(type == 1){
            title = '确认解除当前选项吗？';
        }else{
            title = '确认绑定当前选项吗？';
        }
        var subjectId = $("#subjectId").val();
        if(isEmpty(subjectId)){
            dggui.dialog.info('题目不能为空！');
            return;
        }
        dggui.dialog.confire(title, '操作提示', function () {
            dggui.dialog.loading();
            $.ajax({
                url: sysInfo.basePath + "/rzsc/evaluating/edit_option_binding.do",
                data: {optionId : optionId, handleType : type, subjectId : subjectId},
                success: function (res) {
                    dggui.dialog.loading('close');
                    if (res.code == 0) {
                        window.location.reload();
                        dggui.dialog.succeed(res.msg);
                    } else {
                        dggui.dialog.errors(res.msg);
                    }
                }
            });

        })

    }
</script>
</body>
</html>